package com.wwg.spring.bean.factory;

import org.springframework.beans.factory.FactoryBean;

/**
 * @类描述: TODO
 * @Author wwg
 * @date: 2021/7/16 13:29
 * @Version: 1.0
 **/
public class MyCarFactoryBean implements FactoryBean<Car> {

    private String text;
    private String year;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    @Override
    public Car getObject() throws Exception {
        CarBuilder carBuilder = CarBuilder.car();
        carBuilder.setYear(this.year);
        carBuilder.setText(this.text);
        return carBuilder.getCar();
    }

    @Override
    public Class<?> getObjectType() {
        return Car.class;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
